package org.metasketch.diagram.javafx.graphics;

import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.control.Label;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.text.TextAlignment;

public class Test extends Group {

	// Pane group = new Pane();

	// BorderPane labelPane = new BorderPane();

	Line top = new Line();
	Line bottom = new Line();
	Line left = new Line();
	Line right = new Line();
	Label label = new Label("Untitled");
	protected int x;
	protected int y;
	protected int width;
	protected int height;

	Color lineColor = Color.DARKGRAY;

	public Test(int x, int y, int width, int height) {
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;

		// getChildren().add(labelPane);
		// labelPane.setCenter(label);
		// label.setAlignment(Pos.BASELINE_CENTER);

		setTranslateX(x);
		setTranslateY(y);
		// pane.set

		// Rectangle r = new Rectangle(width, height);
		// r.setTranslateX(gnode.getX());
		// r.setTranslateY(gnode.getY());
		// r.setFill(Color.BLUE);

		// Line line = new Line();
		top.setStroke(lineColor);
		top.setStrokeWidth(4);
		top.setStartX(1);
		top.setStartY(1);
		top.setEndX(width);
		top.setEndY(1);

		bottom.setStroke(lineColor);
		bottom.setStrokeWidth(4);
		bottom.setStartX(1);
		bottom.setStartY(height);
		bottom.setEndX(width);
		bottom.setEndY(height);

		left.setStroke(lineColor);
		left.setStrokeWidth(4);
		left.setStartX(1);
		left.setStartY(1);
		left.setEndX(1);
		left.setEndY(height);

		right.setStroke(lineColor);
		right.setStrokeWidth(4);
		right.setStartX(width);
		right.setStartY(1);
		right.setEndX(width);
		right.setEndY(height);

		label.setTranslateY(5);
		label.setTranslateX(5);
		label.setTextAlignment(TextAlignment.CENTER);
		label.setAlignment(Pos.TOP_CENTER);
		label.setWrapText(true);
		label.setMaxWidth(width - 10);
		label.setPrefWidth(width - 10);
		// label.setStyle("-fx-background-color: #ff0000");
		// centerLabel();
		// line.getTransforms().add(Transform.translate(gnode.getX(),
		// gnode.getY()));
		// line.setTranslateX(gnode.getX());
		// line.setTranslateY(gnode.getY());

		// getChildren().add(r);
		// getChildren().add(line);

		getChildren().addAll(top, bottom, left, right, label);
	}

	// private void centerLabel() {
	// // label.set
	// // double halfLabelWidth = label.getWidth() / 2.0;
	// //
	// // double halfTotalWidth = width / 2.0;
	// //
	// // label.setTranslateX(halfTotalWidth);
	//
	// }

}
